<?php

class Tools extends CI_Controller {

	public function __construct() {
		// 调用父类的构造方法
		parent::__construct();
		// 加载学生信息模型，并简写为task
		$this->load->model('Dict_model', 'dict');
	}

	public function index() {
		$this->load->view('tools.html');

	}

	public function getResult($content = '') {

		// echo 'It Works!';
		$content = $this->input->post('content');
		// 将content作为参数，获取翻译的结果
		$data = $this->dict->translate($content);
		// var_dump($data);
		if (isset($data['basic']['explains'])) {
			foreach ($data['basic']['explains'] as $key => $value) {
				echo $value;
			}
		} elseif (isset($data['translation'])) {
			echo $data['translation'][0];
		} else {
			echo '没找到';
		}

	}
} // 大类结束
